//
//  FilterCallTelephoneNumber.m
//  mcrmSAAS
//
//  Created by busy life987 on 15-11-2.
//  Copyright (c) 2015年 GuangZhouXuanWu. All rights reserved.
//

#import "FilterCallTelephoneNumber.h"



@implementation FilterCallTelephoneNumber
static FilterCallTelephoneNumber *s_filterTelephoneNo;

+(void)filterCallTelephoneNumber:(NSString *)callNumber
{
    if (s_filterTelephoneNo == nil)
        s_filterTelephoneNo = [FilterCallTelephoneNumber new];
    [s_filterTelephoneNo filterSpecialSymbolFromCallNumber:callNumber];
}

-(void)filterSpecialSymbolFromCallNumber:(NSString *)callNumber
{
    NSString * resultStr = @"";
    NSString *regex = @"^[0-9]+$";
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    
    for (int i =0 ;i< [callNumber length];i++) {
        NSString *s = [callNumber substringWithRange:NSMakeRange(i, 1)];
        if ([predicate evaluateWithObject:s]) {
            resultStr = [resultStr stringByAppendingString:s];
        }
    }
    [XMSCallTelephone callTelephone:resultStr];
}

@end
